<?php
include "../../../lib/list.php";
if($_GET['buyer']){
	$buyer = $_GET['buyer'];
	$sear_char .= " and uatp_product.buyer = $buyer ";
}
if($_GET['date']){
	$date = $_GET['date'];
	$sear_char .= " and uatp_prdgroup.date = '$date' ";
}
if($_GET['g_no']){
	$g_no = $_GET['g_no'];
	$sear_char .= " and uatp_prdgroup.no = '$g_no' ";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/print.css" type="text/css"></link>
<script language="javascript">
window.onload = function ()
{
	print();
}
</script>
</head>
<body style="padding:10px;margin:10px;">
        <table width="650"  border="0" height="491" cellpadding="0" cellspacing="0">
                                <tr> 
                                    <td valign="top">
                    <h1 class='rpt_title' style='font-size: 20px; height:25px;'>구&nbsp;입&nbsp;관&nbsp;리&nbsp;표</h1>
             <!-- TopSql 시작 -->
                    <table border="0" cellpadding="0" cellspacing="0" width="650px">
                        <tr>
                           <td style="width:300px;vertical-align:top;">
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
						<?
						$qry = "SELECT uatp_product.productname, uatp_product.barcode, uatp_prdreview.count,uatp_prdreview.in_s_no,
                                uatp_prdreview.in_staff_no, uatp_staff.name AS 'staffname', uatp_shopinfo.name AS 'shopname', uatp_prdreview.price,
								uatp_prdreview.unit, uatp_product.buyer, uatp_buyer.name, uatp_prdgroup.date, uatp_prdgroup.no AS 'g_no'
								FROM uatp_prdreview 
								INNER JOIN uatp_shopinfo ON uatp_prdreview.in_s_no = uatp_shopinfo.no
								INNER JOIN uatp_staff ON uatp_prdreview.in_staff_no = uatp_staff.no
		     		        	INNER JOIN uatp_product ON uatp_prdreview.p_no = uatp_product.no 
		                        INNER JOIN uatp_prdgroup ON uatp_prdreview.g_no = uatp_prdgroup.no
		                        INNER JOIN uatp_buyer ON uatp_product.buyer = uatp_buyer.no
								WHERE 1 $sear_char AND uatp_prdreview.unit='0'";
						$info = DBarray($qry);
						?>
                                        <th style='height:15px'>전표번호</th>
                                        <td><?=date('Ymd',strtotime($info['date']))?>-<?=$info['g_no']?></td>
                                    </tr>
                                    <tr> 
                                        <th style='height:15px'>DATE</th>
                                        <td><?=date('Y/m/d',strtotime($info['date']))?></td>
                                    </tr>
                                </table>
                            </td>
                            <td rowspan="2">&nbsp;</td>
                            <td style="width:340px">
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
                                        <th style='height:15px'>점포명</th>
                                        <td><?=$info['shopname']?></td>
                                    </tr>
                                    <tr>
                                        <th style='height:15px'>담당자</th>
                                        <td><?=$info['staffname']?></td>
                                    </tr>
                                    <tr>
                                        <th style='height:15px'>구매처</th>
                                        <td><?=$info['name']?></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    
                    
                    <!-- TopSql 끝 -->
        
                    <!-- 구매리스트 시작 -->
                    <table class="p_rptC" width="650" >                    
                            <col width="8%" />                            
                            <col width="" />                            
                            <col width="43%" />
                            <col width="9%" />                           
                            <col width="23%" />
                            <thead>
                        <tr>
                                        <th style="height:23px">순번</th>   
                                        <th style="height:23px">품목</th>   
                                        <th style="height:23px">품명 및 규격 </th>   
                                        <th style="height:23px">수량</th>   
                                        <th style="height:23px">가격</th>   
                        </tr>
                           <?php 
                        $result = DBquery($qry);
                 	  	while($list = mysql_fetch_array($result)){
						$bunho++;
						$total_count += $list['count'];
						$total_price += $list['price'];
					?>
                        <tr height="22px;" >
                        <td style="text-align:center;font-size:11px; width:8%;"><?=$bunho?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:17%;">&nbsp;<?=$list['barcode']?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:43%;">&nbsp;<?=$list['productname']?>&nbsp;</td>
                        <td style="text-align:right;font-size:11px; width:9%;"><?=$list['count']?>&nbsp;개&nbsp;</td>
                        <td style="text-align:right;font-size:11px; width:23%;"><?=$list['price']?>&nbsp;￥&nbsp;</td>
                        </tr>
                    <?php
					} ?>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <!-- 구매리스트 끝 -->
                
                    
                    <!-- 각페이지통계 시작(수량, 인수) -->
                    <table class="p_rptB">
                        <col width="100px" />
                        <col />
                        <col width="100px" />
                        <col width="150px" />
                        <tr>
                            <th style='height:13px'>수량</th>
                            <td class="right"><?=$total_count?>&nbsp;개&nbsp;</td>
                            <th style='height:13px'>가격</th>
                            <td class="right"><?=$total_price?>&nbsp;￥&nbsp;</td>
                            <th style='height:13px'>인수</th>
                            <td class="right">인</td>
                        </tr>
                    </table>
                    <!-- 각페이지통계 끝 -->
                    <!-- 추가입력사항 시작 -->
                    <table class="p_rptB2"  style="margin:3px 0 0 0;">
                        <col width="15%" />
                        <col width="35%" />
                        <col width="15%" />
                        <col width="35%" />
                        
                    </table>            
                   </td>
                   </tr>
                   </table>         
</body>
</html>